package com.icinfo.cloud.provider.punish.ucase.punishinform.controller;

import com.icinfo.cloud.common.core.Validator.BaseGroup;
import com.icinfo.cloud.provider.punish.ucase.criminaltransfer.service.ICaseCriminalTransferFileService;
import com.icinfo.cloud.provider.punish.ucase.punishinform.dto.CriminalCaseTransferQueryDto;
import com.icinfo.cloud.provider.punish.ucase.punishinform.dto.CriminalCaseTransferSaveDto;
import com.icinfo.cloud.provider.punish.ucase.punishinform.service.ICaseCriminalTransferService;
import com.icinfo.cloud.provider.punish.ucase.punishinform.vo.CaseCriminalTransferFileVo;
import com.icinfo.cloud.provider.punish.ucase.punishinform.vo.CaseCriminalTransferInfoVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 描述：涉刑移送
 *
 * @author shishengyao
 * @description
 * @date 2022/9/27
 */
@RestController
@RequestMapping("/punish/inform/criminalCaseTransfer")
public class CaseCriminalTransferController extends BaseController {
    /**
     * 日志记录器
     */
    private static final Logger logger = LoggerFactory.getLogger(CaseCriminalTransferController.class);

    @Resource
    private ICaseCriminalTransferService criminalCaseTransferervice;
    @Resource
    private ICaseCriminalTransferFileService caseCriminalTransferFileService;

    /**
     * 【V1.5.0】描述：获取涉刑移送单数据
     *
     * @param queryDto 查询dto
     * @return {@link Result< CaseCriminalTransferInfoVo > }
     * @author shishengyao
     * @date 2022/09/27
     */
    @PostMapping(value = "/getCriminalCaseTransferInfo", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<CaseCriminalTransferInfoVo> getCriminalCaseTransferInfo(@RequestBody @Validated(BaseGroup.Query.class) CriminalCaseTransferQueryDto queryDto) {
        return Result.success(criminalCaseTransferervice.getCriminalCaseTransferInfo(queryDto));
    }

    /**
     * 【V1.5.0】描述：保存涉刑移送表单数据
     *
     * @param saveDto 保存dto
     * @return {@link Result<String> }
     * @author shishengyao
     * @date 2022/09/27
     */
    @PostMapping(value = "/saveCriminalCaseTransfer", produces = MediaType.APPLICATION_JSON_VALUE)
    public Result<String> saveCriminalCaseTransfer(@RequestBody @Validated CriminalCaseTransferSaveDto saveDto) {
        if (criminalCaseTransferervice.saveCriminalCaseTransfer(saveDto) < 1) {
            return Result.error("保存失败");
        }
        return Result.success("保存成功");
    }


    /**
     * 【1.5.0】查询证据列表（涉刑移送）
     *
     * @param queryDto 查询dto
     * @return {@link Result<List< CaseCriminalTransferFileVo >> }
     * @author shishengyao
     * @date 2022/09/26
     */
    @PostMapping("/getCriminalCaseTransferEvidenceList")
    @ApiOperation(value = "【1.5.0】查询涉刑案件文书列表", httpMethod = "POST")
    public Result<List<CaseCriminalTransferFileVo>> getCriminalCaseTransferEvidenceList(@RequestBody @Validated CriminalCaseTransferQueryDto queryDto) {
        List<CaseCriminalTransferFileVo> voList = criminalCaseTransferervice.getCriminalCaseTransferEvidenceList(queryDto);
        return Result.success(voList);
    }

    /**
     * 【1.5.0】查询文书列表（涉刑移送）
     *
     * @param queryDto 查询dto
     * @return {@link Result<List< CaseCriminalTransferFileVo >> }
     * @author shishengyao
     * @date 2022/09/26
     */
    @PostMapping("/getDocumentRecordOfCriminal")
    @ApiOperation(value = "【1.5.0】查询涉刑案件文书列表", httpMethod = "POST")
    public Result<List<CaseCriminalTransferFileVo>> getDocumentRecordOfCriminal(@RequestBody @Validated CriminalCaseTransferQueryDto queryDto) {
        List<CaseCriminalTransferFileVo> voList = criminalCaseTransferervice.getCriminalCaseTransferDocumentList(queryDto);
        return Result.success(voList);
    }

    /**
     *【1.5.0】 描述： 获取涉刑案件移送文件列表（证据材料）
     *
     * @param queryDto
     * @return {@link Result<List< CaseCriminalTransferFileVo >> }
     * @author shishengyao
     * @date 2022/10/10
     */
    @PostMapping("/getCriminalCaseTransferFileList")
    public Result<List<CaseCriminalTransferFileVo>> getCriminalCaseTransferFileList(@RequestBody @Validated(BaseGroup.Query.class) CriminalCaseTransferQueryDto queryDto) {
        return Result.success("获取成功", caseCriminalTransferFileService.getCaseCriminalTransferFileListByCaseId(queryDto.getCaseId()));
    }
}
